﻿using System;

using Ah.Testudin.Engine.Actors.Components.Animation;
using Ah.Testudin.Engine.Events;

using Microsoft.Xna.Framework;

namespace Ah.Testudin.Engine.Actors.Components.Collision
{
    public class StopAnimationCollisionHandlerComponent : ActorComponentBase, ICollisionHandlerComponent
    {
        #region Constructors

        public StopAnimationCollisionHandlerComponent(
            Actor owner,
            IEventManager eventManager)
            : base(owner, eventManager)
        {
        }

        #endregion

        #region IActorComponent

        public override void Update(GameTime gameTime)
        {
        }

        #endregion

        #region ICollisionHandlerCompnent

        public void HandleCollision()
        {
            IAnimationComponent animationComponent = this.Owner.GetComponent<IAnimationComponent>();

            if (animationComponent != null)
            {
                animationComponent.Status = AnimationStatus.Finished;
            }

            this.Owner.SetComponent<ICollisionHandlerComponent>(null);
        }

        #endregion
    }
}
